#include <algorithm>
#include <cstdio>
#include <vector>

const int N = 805;
int n, m, sum[N][N], sumrac[N];
char map[N][N];

struct Node {
  int x, y;
  Node(int x, int y) : x(x), y(y) {}
};

std::vector<Node> vec;
int rowpos, colpos;

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#else
  freopen("hit.in", "r", stdin);
  freopen("hit.out", "w", stdout);
#endif
#endif

  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", map[i] + 1);
    for (int j = 1; j <= m; ++j)
      if (map[i][j] == '*') vec.push_back(Node(i, j));
  }

  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      sum[i][j] = sum[i][j - 1];
      if (map[i][j] == '*') sum[i][j]++;
    }
  }
  for (int i = 1; i <= n; ++i) { sumrac[i] = sumrac[i - 1] + sum[i][m]; }
  for (int i = 1; i <= n; ++i) {
    if (sumrac[i - 1] > sumrac[n] - sumrac[i]) {
      rowpos = i;
      break;
    }
  }

  for (int i = 1; i <= m; ++i) {
    for (int j = 1; j <= n; ++j) {
      sum[j][i] = sum[j - 1][i];
      if (map[j][i] == '*') sum[j][i]++;
    }
  }
  for (int i = 1; i <= m; ++i) { sumrac[i] = sumrac[i - 1] + sum[n][i]; }
  for (int i = 1; i <= m; ++i) {
    if (sumrac[i - 1] > sumrac[m] - sumrac[i]) {
      colpos = i;
      break;
    }
  }
  
  int ans = 0x3f3f3f3f;
  for (int i = rowpos; i > rowpos - 2; --i) {
    for (int j = colpos; j > colpos - 2; --j) {
      int tmp = 0;
      for (std::vector<Node>::iterator iter = vec.begin(); iter != vec.end(); ++iter) {
        tmp += std::abs(i - iter->x) + std::abs(j - iter->y);
      }
      ans = std::min(ans, tmp);
    }
  }
  printf("%d", ans);
  return 0;
}